<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>还款银行卡登记</title>
	<link rel="stylesheet" href="../css/style.css">
	<link rel="stylesheet" href="../css/common.css">
	<link rel="stylesheet" type="text/css" href="../css/public.css"/>
	<link rel="stylesheet" href="../css/swiper.min.css">
	<script src="../js/index1.js"></script>
	<script src="../js/jquery.js"></script>
	<script src="../js/dyselect.js"></script>
	<script src="../js/swiper.min.js"></script>
	<script src="../js/rem-config.js"></script>

</head>
<body>
<div class="tabbar">
	<a href="mine.html" class="tabbar_r">
		<img src="../images/x.png" >
	</a>
	<span>还款银行卡登记</span>
	<a href="" class="tabbar_c">
		<img src="../images/caidan.png" alt="">
	</a>
	<div class="clear"></div>
</div>
<div class="f_banner">
	<img src="../images/banner.jpg" alt="">
</div>
<div class="progress_bar">
	<div class="yellow"></div>
	<div class="yellow"></div>
	<div class="yellow"></div>
	<div class="yellow"></div>
	<div class="yellow"></div>
	<div class="yellow"></div>
	<div class="yellow"></div>
	<div class="yellow"></div>
	<div class="yellow"></div>
</div>
<div class="phone_content">
	<ul>
		<li>
			<span>账 &nbsp; &nbsp;号 </span>
			<input type="text" placeholder="银行卡账号" class="phone_num reg_yhk">
		</li>
		<li>
			<span>开户行</span>
			<div class="phone_yunying1 btn1">
				<span class="reg_yinhang">选择银行</span>
				<img src="../images/xiaosanjiao.png" alt="">
			</div>
		</li>
		<li>
			<span>手机号</span>
			<input type="text" placeholder="请输入手机号" class="phone_num reg_phone">
		</li>
		<li>
			<input type="text" placeholder="请输入4位短信验证码" class="phone_yanzhengma reg_yzm">
			<div class="phone_hq">获取验证码</div>
		</li>
	</ul>
</div>
<div class="btn_box">
	<div>上一步</div>
	<div class="next_btn">下一步</div>
</div>
<div class="msg"></div>
<div class="dialog show1">
	<div class="dialog_bg"></div>
	<div class="dialog_info">
		<ul>
			<li>java开发工程师</li>
			<li>java开发工程师</li>
			<li>java全栈开发工程师</li>
		</ul>
		<a href="javascript:;" class="dialog_btn show1_cancle">取消</a>
	</div>
</div>

</body>
<script>
    $(function() {
        $(".btn1").click(function() {
            $(".show1").show();
            $.ajax({
                url:appPath+"kaihuhangDropdownBox",
                data:"",
                dataType:'json',//服务器返回json格式数据
                type:'get',//HTTP请求类型
                success:function(res){
                    if(res.success){
                        var _list = res.data;
                        var _li = "";
                        for(var i = 0;i<_list.length;i++){
                            _li+="<li li_id="+_list[i].id+">"+_list[i].name+"</li>";

                        }
                        $(".dialog.show1 ul").html(_li);

                    }else{
                        $(".msg").show().text("获取失败！原因"+res.errorMessage);
                        setTimeout(function(){
                            $(".msg").hide("slow")
                        },2000)
                    }
                }
            });
        })
        $(".show1_cancle").click(function() {
            $(".show1").hide();
        })
        // 获取文字再放上去
        $(".dialog").on("click","li",function() {
            var li_text = $(this).text();
            var li_id = $(this).attr("li_id")
            if ($(this).parent().parent().parent().hasClass("show1")) {
                $(".btn1 span").text(li_text);
                //获取id属性
                $(".btn1 span").attr("li_id",li_id);

            }
            $(".dialog").hide();
        })
        //点击
        $('.next_btn').click(function(){
            // 判断是否为空,并正则验证
            $(".reg_yhk").blur(function(){
                if($(this).val()==""){
                    $(".msg").show().text("不能为空");
                    $(this).focus();
                    setTimeout(function(){
                        $(".msg").hide("slow")
                    },2000)

                    return false;
                }else{
                    var _yhk = $(this).val();
                    var myreg=/^([1-9]{1})(\d{14}|\d{18})$/;
                    if(!myreg.test(_phone)){
                        $(".msg").show().text("银行卡号不合法");
                        setTimeout(function(){
                            $(".msg").hide("slow")
                        },2000);
                        $(this).focus();
                    }
                }
            });
            if($('.reg_yinhang').text()=="选择银行"){
                $(".msg").show().text("不能为空");
                setTimeout(function(){
                    $(".msg").hide("slow")
                },2000)
                return false;
            };
            $(".reg_phone").blur(function(){
                if($(this).val()==""){
                    $(".msg").show().text("不能为空");
                    $(this).focus();
                    setTimeout(function(){
                        $(".msg").hide("slow")
                    },2000)

                    return false;
                }else{
                    var _phone = $(this).val();
                    var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
                    if(!myreg.test(_phone)){
                        $(".msg").show().text("手机号不合法");
                        setTimeout(function(){
                            $(".msg").hide("slow")
                        },2000);
                        $(this).focus();
                    }
                }
            });
            $("reg_yzm").blur(function(){
                if($(this).val()==""){
                    $(".msg").show().text("不能为空");
                    $(this).focus();
                    setTimeout(function(){
                        $(".msg").hide("slow")
                    },2000)

                    return false;
                }else{
                    var _yzm = $(this).val();
                    var myreg=/^\d{4}$/;
                    if(!myreg.test(_yzm)){
                        $(".msg").show().text("验证码不合法");
                        setTimeout(function(){
                            $(".msg").hide("slow")
                        },2000);
                        $(this).focus();
                    }
                }
            });
            var _yhk = $('.reg_yhk').val();
            var _yinhang = $('.reg_yinhang').attr("li_id");
            var _phone = $('.reg_phone').val();
            var _yzm = $('.reg_yzm').val();
            var _data = {
                "bankCardAccount":_yhk,
                "openingBank":_yinhang,
                "bankPhone":_phone,
                "verificationCode":_yzm
            }
				 $.ajax({
					url:appPath+"userRepay/add",
                     data:JSON.stringify(_data),
                     contentType: "application/json;charset=utf-8",
				 	dataType:'json',//服务器返回json格式数据
				 	type:'post',//HTTP请求类型
				 	success:function(res){
				 		if(res.success){
							$('.msg').show().text("成功！1秒后跳转")
							setTimeout(function(){
								window.location.href = "xuezhufenqi.html"
							},1000)
						}else{
							$('.msg').show().text("失败！原因"+res.errorCode)
							setTime(function(){
								$('.msg').hide("slow")
							},2000)
						}
					},
				});
				
			})
		
		});
	</script>
</html>
